/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import java.nio.ByteBuffer;
import java.nio.IntBuffer;

/**
 *
 * @author LTTDNQ
 */
public class Convert {

    public Convert() {
    }

    public int[] ByteToInt(byte[] _arrByteArray) {

        int[] _intArray = new int[_arrByteArray.length];

        //converting byteArray to intArray
        for (int i = 0; i < _arrByteArray.length; i++) {
            
        _intArray[i] = (int)_arrByteArray[i];      
//            _intArray[i] = _arrByteArray[3 + i * 4] & 0xFF
//                    | (_arrByteArray[2 + i * 4] & 0xFF) << 8
//                    | (_arrByteArray[1 + i * 4] & 0xFF) << 16
//                    | (_arrByteArray[1 + i * 4] & 0xFF) << 24;

        }
        return _intArray;

    }
    public byte[] IntToByte(int[] _arrInt) {
        int srcLength = _arrInt.length;
        byte[] dst = new byte[srcLength << 2];

        for (int i = 0; i < srcLength; i++) {
            int x = _arrInt[i];
            int j = i << 2;
            dst[j++] = (byte) ((x >>> 0) & 0xff);
            dst[j++] = (byte) ((x >>> 8) & 0xff);
            dst[j++] = (byte) ((x >>> 16) & 0xff);
            dst[j++] = (byte) ((x >>> 24) & 0xff);
        }
        return dst;
    }
}
